package com.itany.corejava.day04;

public class Test6 {

    public static void main(String[] args) {


        System.out.println(roundInt(2.4));
        System.out.println(roundInt(2.6));
        System.out.println(Test6.roundInt(2.4));
        
        int result=roundInt(2.2);

        System.out.println("result = " + result);
        
        


    }

    public static int roundInt(double num){

        if(num<0){
            //应该使用异常来处理，后期处理
            System.out.println("这个方法只能对正数做四舍五入");
            return -1;//这个返回不合理，后面异常解决
        }

        int result= (int) (num+0.5);

        return result;
    }
}
